<div class="nodesSort">
<?php _e('Sort by ');select_to_remote('sortby', $requested_sortby, 'xigg-admin-tag-list', array('name,ASC' => _('Name ascending'), 'name,DESC' => _('Name descending'), 'created,ASC' => _('Created date')), array('base' => '/tag/list', 'params' => array()), _('Go'));?>
</div>
<?php form_tag('post', Sabai_URL::get('/tag/submit'), array('id' => 'xigg-admin-tag-list-form'));?>
  <table>
    <thead>
      <tr>
        <th class="left"><input id="xigg-admin-tag-list-form-checkall" type="checkbox" onclick="$$('#xigg-admin-tag-list-form input.check').each(function(ele){ele.checked=$('xigg-admin-tag-list-form-checkall').checked});" /></th>
        <th class="left"><?php _e('Name');?></th>
        <th><?php _e('Created');?></th>
        <th><?php _e('Articles');?></th>
        <th scope="col"><?php _e('Action');?></th>
      </tr>
    </thead>
    <tfoot>
      <tr>
        <td colspan="3" class="left">
          <input type="submit" name="empty" value="<?php _e('Empty');?>" />
          <input type="submit" name="delete" value="<?php _e('Delete');?>" />
        </td>
        <td colspan="3" class="right"><?php echo $this->helper('PageNavRemote', 'xigg-admin-tag-list', $entity_pages, $entity_page_requested, array('base' => '/tag/list', 'params' => array('sortby' => $requested_sortby)));?></td>
      </tr>
    </tfoot>
    <tbody>
<?php while ($e =& $entity_objects->getNext()):?>
<?php   $tag_nodes =& $e->get('Nodes');?>
      <tr>
        <td class="left"><input type="checkbox" class="check" name="tags[]" value="<?php echo $e->getId();?>" /></td>
        <td class="left"><a href="<?php echo $e->getLink(SABAI_URL_DIR. '/index.php');?>"><?php _h(Sabai_I18N::strcutMore($e->getLabel(), 100));?></a></td>
        <td><?php _h($this->helper('XiggAgo', $e->getTimeCreated()));?></td>
        <td><?php echo $tag_nodes->size();?></td>
        <td><?php link_to_remote(_('Edit'), 'xigg-admin-tag-list-update', array('base' => '/tag/' . $e->getId() . '/edit'));?> <?php link_to_remote(_('Delete'), 'xigg-admin-tag-list-update', array('base' => '/tag/' . $e->getId() . '/delete'));?></td>
      </tr>
<?php endwhile; ?>
    </tbody>
  </table>
<input type="hidden" name="_TOKEN" value="<?php echo $this->helper('Token', 'Admin_tag_submit');?>" />
<?php form_tag_end();?>

<div class="addEntityLink">
<?php link_to_remote(_('Add tag'), 'xigg-admin-tag-list-update', array('base' => '/tag/add'));?>
</div>

<div id="xigg-admin-tag-list-update"></div>

<h3><?php _e('Delete empty tags');?></h3>
<p><?php _e('Press the button below to delete all tags that do not have any nodes assciated with.');?></p>
<?php form_tag('post', Sabai_URL::get('/tag/delete_empty_tags'));?>
  <input type="submit" value="<?php _e('Delete empty tags');?>" />
  <input type="hidden" name="_TOKEN" value="<?php echo $this->helper('Token', 'Admin_tag_delete_empty_tags');?>" />
</form>